package com.chinaisafe.user.vo.request;

import com.chinaisafe.base.common.vo.request.PageReqVo;
import com.chinaisafe.base.common.validated.AddGroup;
import com.chinaisafe.base.common.validated.QueryGroup;
import com.chinaisafe.base.common.validated.UpdateGroup;
import jakarta.validation.constraints.NotNull;

import java.time.LocalDate;
import java.time.LocalDateTime;
import com.chinaisafe.user.entity.SysRoleMenu;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Transient;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
 * SysRoleMenuReqVO
 * Description：角色与菜单请求值对象
 *
 * @author xuefu.shu
 * @date  2024-07-13 17:14:06
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysRoleMenuReqVO", description = "角色与菜单请求值对象")
public class SysRoleMenuReqVO extends PageReqVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    @NotNull(groups = UpdateGroup.class, message = "主键id不能为空" )
    private Long id;

    @Schema(description = "乐观锁版本")
    private Integer version;

    @Schema(description = "角色_id")
    private Long sysRoleId;

    @Schema(description = "菜单(资源)_id")
    private Long sysMenuId;

    @Schema(description = "应用id")
    @NotNull(groups = QueryGroup.class, message = "应用id不能为空" )
    private Long sysAppId;

    @Transient
    private List<Long> myRoleIds;




    /**
     * 将请求值对象装换为实体
     * @return SysRoleMenu
     * @author xuefu.shu
     * @date 2024-07-13 17:14:06
     */
    public SysRoleMenu convertToEntity() {
        SysRoleMenu entity = new SysRoleMenu();
        entity.setId(this.id);
        entity.setVersion(this.version);
        // 给实体对应的字段赋值 可根据实际业务删减
        entity.setSysRoleId(this.sysRoleId);
        entity.setSysMenuId(this.sysMenuId);
        return entity;
    }
}
